-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for calculate_index function #495
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
for more information, see https://pre-commit.ci
Hey @jamesturner246 , @alexdewar. This is ready for a review now, when you have time. The Windows build is failing for reasons I can't quite get to the bottom of, but I'll have more of a poke around and see if I can fixt that. |
@TinyMarsh The Windows build is failing because of a missing I had the same problem on my branch. Fix here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good on the whole -- and the test module seems useful. There are a couple of unused functions you've added though and I think we could do with a few more test cases for calculate_index
.
|
||
size_t index_1 = analysis_module->calculate_index(test_person_1); | ||
|
||
ASSERT_EQ(index_1, 29); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to test some more indexes here? E.g. you could check it works with 1, 2 and 3 dimensional matrices
Thanks @alexdewar. Yes absolutely we could probably do with more test cases. I meant to do that but I think I just got excited that I actually managed to get a test running and rushed out a PR 😄. I will add some more cases and clean up the code per your other comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good! Much has already been stated, just a couple minor things and a question.
As @alexdewar says, maybe a couple more tests/cases in this PR and looks god to go!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## extend_analysis #495 +/- ##
==================================================
Coverage ? 49.92%
==================================================
Files ? 160
Lines ? 7732
Branches ? 1027
==================================================
Hits ? 3860
Misses ? 3677
Partials ? 195 ☔ View full report in Codecov by Sentry. |
Hi @alexdewar @jamesturner246 this should be ready for a re-review now. I have made some changes based on your feedback. I noticed an error in the logic of the The testing of varying dimensions will have to be done later (I will create an issue), as we currently have it hard-coded for 2 dimensions (age and gender in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some mysterious commented-out code, but other than that, this LGTM!
src/HealthGPS/analysis_module.cpp
Outdated
std::ref(context), std::ref(result)); | ||
// auto handle = core::run_async(&AnalysisModule::calculate_historical_statistics, this, | ||
// std::ref(context), std::ref(result)); | ||
// handle.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good spot. It shouldn't be commented out. This is left over from when I was trying to debug the test failing. With these two lines uncommented, I get the following test failure;
Start 236: TestAnalysisModule.CalculateIndex
236/236 Test #236: TestAnalysisModule.CalculateIndex ..............................***Failed 0.07 sec
Initialising with a custom GTest main function.
Using default test data store ...
Test location..: /home/ryan/projects/healthgps/out/build/linux-debug/src/HealthGPS.Tests
Test data store: /home/ryan/projects/healthgps/data
Note: Google Test filter = TestAnalysisModule.CalculateIndex
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TestAnalysisModule
[ RUN ] TestAnalysisModule.CalculateIndex
unknown file: Failure
C++ exception with description "map::at" thrown in the test fixture's constructor.
[ FAILED ] TestAnalysisModule.CalculateIndex (57 ms)
[----------] 1 test from TestAnalysisModule (57 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (57 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] TestAnalysisModule.CalculateIndex
1 FAILED TEST
99% tests passed, 1 tests failed out of 236
Total Test time (real) = 15.35 sec
The following tests FAILED:
236 - TestAnalysisModule.CalculateIndex (Failed)
Errors while running CTest
I think this is because the RuntimeContext
object that is created in the test fixture constructor is not properly initialised with the required map elements for some map that the commented-out handle.get()
function above is trying to access.
Not quite there yet then. I feel like this is going to be a pain to sort out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and wasn't too bad in the end. The RuntimeContext
needed the current year to be set.
Turns out that I thought it would be worth creating a separate PR for implementing this test as I've decided to be more thorough with things.
While creating the test fixtures I noticed that there existed some code in
Simulation.Test.cpp
to help create the fixtures I was using inAnalysisModule.Test.cpp
. I have moved much of this code tosimulation.h
/.cpp
and have both test files include this header.Closes #470